<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>loading...</title>
<link rel="stylesheet" href="__PUBLIC__/libs/dingding/stylesheets/style.css" type="text/css" />
        <!-- config中signature由jsticket产生，若jsticket失效，则signature失效，表现为dd.error()返回“权限校验失败”之错误。 -->
        <!-- 在请求新的jsticket之后，旧的ticket会失效，导致旧ticket产生的signature失效。 -->
        <link rel="stylesheet" href="http://g.alicdn.com/ilw/ding/0.2.3/styles/main.css?v=262192719_110744" type="text/css"/>
        <script type="text/javascript">var _config = <?php echo Auth::getConfig();?></script>
        <script type="text/javascript" src="__PUBLIC__/libs/dingding/javascripts/zepto.min.js"></script>
        <script type="text/javascript" src="https://g.alicdn.com/ilw/ding/0.8.9/scripts/dingtalk.js"></script> 
       
        
</head>
<body>

	<script type="text/javascript" src="__PUBLIC__/libs/dingding/javascripts/logger.js"></script>
        <script type="text/javascript" >
        dd.config({
            agentId: _config.agentId,
            corpId: _config.corpId,
            timeStamp: _config.timeStamp,
            nonceStr: _config.nonceStr,
            signature: _config.signature,
            jsApiList: [
            	'runtime.permission.requestAuthCode',
                'runtime.info',
                'device.base.getUUID',
                'device.notification.prompt',
                'device.base.getInterface',
                'biz.chat.pickConversation',
                'device.notification.confirm',
                'device.notification.alert',
                'device.notification.prompt',
                'biz.chat.open',
                'biz.util.open',
                'biz.user.get',
                'biz.contact.choose',
                'biz.telephone.call',
                'biz.ding.post']
        });
        dd.userid=0;
        dd.ready(function() {
           
            dd.runtime.permission.requestAuthCode({
                corpId: _config.corpId, //企业id
                onSuccess: function (info) {
                   // logger.i('authcode: ' + info.code);
                    
                    $.ajax({
                        url: '/Home/Taskwap/get_userinfo',
                        type:"POST",
                        data: {"code":info.code},
                        dataType:'json',
                        timeout: 900,
                        success: function (data, status, xhr) {
                            var info = JSON.parse(data);
                            if (info.errcode === 0) {
                                //logger.i('user id: ' + info.userid);
                               window.location.href='/Home/Taskwap/mytask';
                               // DingTalkPC.userid = info.userid;
                            }
                            else {
                               // logger.e('auth error: ' + data);
                            }
                        },
                        error: function (xhr, errorType, error) {
                           // logger.e(errorType + ', ' + error);
                        }
                    });
                },
                onFail: function (err) {
                    //logger.e('requestAuthCode fail: ' + JSON.stringify(err));
                }
            });
            
            
         
        });

        dd.error(function(err) {
           // alert('dd error: ' + JSON.stringify(err));
        });
       

   
        
        </script>  
   
   
</body>
</html>
